package com.hecate.common.response;

import java.io.Serializable;

/**
 * @author 黄星星
 * @date 2020-12-08
 */
public class HecateResponse<T> implements Serializable {

    private Integer code;

    private String message;

    private Object data;

    public HecateResponse() {
    }

    public HecateResponse(HecateResponseCodeEnum hecateResponseCodeEnum, String message, Object data) {
        this.code = hecateResponseCodeEnum.getCode();
        this.message = message;
        this.data = data;
    }

    public HecateResponse(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public HecateResponse(Integer code, Object data) {
        this.code = code;
        this.data = data;
    }

    /**
     * 返回成功
     * @return
     */
    public static HecateResponse SUCCESS(){
        HecateResponse result = new HecateResponse();
        result.setCode(HecateResponseCodeEnum.SUCCESS.getCode());
        return result;
    }

    /**
     * 返回成功
     * @param data
     * @return
     */
    public static HecateResponse SUCCESS(Object data){
        HecateResponse result = new HecateResponse();
        result.setCode(HecateResponseCodeEnum.SUCCESS.getCode());
        result.setData(data);
        return result;
    }

    /**
     * 返回失败
     * @param hecateResponseCodeEnum
     * @return
     */
    public static HecateResponse ERROR(HecateResponseCodeEnum hecateResponseCodeEnum){
        HecateResponse result = new HecateResponse();
        result.setCode(hecateResponseCodeEnum.getCode());
        return result;
    }

    public static HecateResponse ERROR(String message){
        HecateResponse result = new HecateResponse();
        result.setCode(HecateResponseCodeEnum.ERROR.getCode());
        result.setMessage(message);
        return result;
    }

    /**
     * 返回失败
     * @param message
     * @return
     */
    public static HecateResponse ERROR(HecateResponseCodeEnum hecateResponseCodeEnum, String message){
        HecateResponse result = new HecateResponse();
        result.setMessage(message);
        result.setCode(hecateResponseCodeEnum.getCode());
        return result;
    }

    /**
     * 返回失败
     * @param hecateResponseCodeEnum
     * @param data
     * @return
     */
    public static HecateResponse ERROR(HecateResponseCodeEnum hecateResponseCodeEnum, Object data){
        HecateResponse result = new HecateResponse();
        result.setCode(hecateResponseCodeEnum.getCode());
        result.setData(data);
        return result;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
